package com.sweetguy.entity;

import com.mybatisflex.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 *  实体类。
 *
 * @author SweetGuy
 * @since 2024-12-22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "comment", schema = "ml_cms")
public class Comment implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键，自增
     */
    @Id(keyType = KeyType.Auto)
    private Long id;

    /**
     * 集次ID,集次表外键
     */
    private Long fkEpisodeId;

    /**
     * 用户ID，用户表外键
     */
    private Long fkUserId;

    /**
     * 评论人姓名，非空
     */
    private String nickname;

    /**
     * 父评论主键，0视为根节点
     */
    private Long pid;

    /**
     * 评论内容，非空
     */
    private String content;

    /**
     * 数据版本，非空，默认值为0
     */
    @Column(version = true)
    private Long version;

    /**
     * 逻辑删除标记，非空，默认值为0表示未删除，1表示已删除
     */
    @Column(isLogicDelete = true)
    private Integer deleted;

    /**
     * 创建时间，非空，默认为当前时间
     */
    private LocalDateTime created;

    /**
     * 更新时间，非空，默认为当前时间，记录更新时自动修改
     */
    private LocalDateTime updated;

    /** 评论[N] : 视频集[1] */
    @RelationManyToOne(selfField = "fkEpisodeId", targetField = "id")
    private Episode episode;
}
